package tmp;

import lombok.Data;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

/**
 * Created by dycong on 2017/8/19.
 */
@Data
public class SonClass extends Father {
    private String name;

    public SonClass clone() throws CloneNotSupportedException {
        SonClass son = (SonClass) super.clone();
        son.setName(this.getName());
        return son;
    }

    public SonClass() {
        //todo 初始化子类时，当在父类的构造方法调用一个被子类覆盖的方法的时候，再调用父类的构造时，调用的方法 print() 是子类的实现
        print();
    }

    public void print() {
        System.out.println(12);
        System.out.println(new Date());
    }

    public static String pop(){

        return SonClass.class.getName();
    }

    public static void main(String[] args) {
        String str = "";
        Integer i = 0;

        Father father = new Father();
        SonClass son = new SonClass();
        father = son;
        son = (SonClass) father;
        son.setAge(1);
        son.setAge2(2);

        /*todo 子类不可以访问父类的private域，但是会继承父类的私有域属性，通常会有公开的set/get方法来暴露父类的私有域*/
        System.out.println(Father.house);
        System.out.println(father.age2);
        System.out.println(father.getAge());

        Father father1 = new SonClass();
        System.out.println(father1.pop());
    }
}
